from django.conf.urls import url
from rest_framework_jwt.views import obtain_jwt_token
from rest_framework.routers import DefaultRouter

from bigevent_admin.views.users import UserView,UserInfoView, UserUpdatePwdView,UserUpdateImgView
from bigevent_admin.views import users,articles
urlpatterns = [
    # 注册路由
    url(r'^api/reguser$', UserView.as_view()),
    # 登陆路由
    url(r'^api/login$', obtain_jwt_token),
    #用户信息查询
    url(r'^my/userinfo$', UserInfoView.as_view()),
    #更新密码
    url(r'^my/updatepwd$', UserUpdatePwdView.as_view()),
    # 更新头像
    url(r'^my/update/avatar$', UserUpdateImgView.as_view()),

     # ---------------文章分类-----------------------------
    # 分类列表获取
    url(r'^my/article/cates$', articles.ArticleCategoriesView.as_view({'get': 'list'})),
    # # 新建分类
    url(r'^my/article/addcates$', articles.ArticleCategoriesView.as_view({'post': 'create'})),
    # # 删除分类
    url(r'^my/article/deletecate/(?P<pk>\d+)$', articles.ArticleCategoriesView.as_view({'get': 'destroy'})),
     # 获取分类数据
    url(r'^my/article/cates/(?P<pk>\d+)$', articles.ArticleCategoriesView.as_view({'get': 'retrieve'})),
    # # 更新分类
    url(r'^my/article/updatecate$', articles.ArticleCategoriesView.as_view({'post': 'update'})),

    # ---------------文章-----------------------------
    # 文章列表获取
    url(r'^my/article/list$', articles.ArticleView.as_view({'get': 'list'})),
    # # 新建文章
    url(r'^my/article/add$', articles.ArticleView.as_view({'post': 'create'})),
    # # 删除文章
    url(r'^my/article/delete/(?P<pk>\d+)$', articles.ArticleView.as_view({'get': 'destroy'})),
    # 获取文章数据
    url(r'^my/article/null$', articles.ArticleView.as_view({'get': 'retrieve'})),
    # # 更新文章
    url(r'^my/article/edit$', articles.ArticleView.as_view({'post': 'update'})),

]

#文章分类模块 路由注册
# router = DefaultRouter()
# router.register(r'^my/article',articles.ArticleCategoriesView,base_name='article_cate')
# urlpatterns += router.urls
print(urlpatterns)
